From d82ed034277013aaf246054dbdf8439e1c5799b5 Mon Sep 17 00:00:00 2001
From: Bartek Brak <bartosz.brak@estoremedia.com>
Date: Tue, 21 Jun 2022 12:39:35 +0200
Subject: [PATCH] fix buffer overflow

https://bugs.archlinux.org/task/74041
---
 utf8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utf8.c b/utf8.c
index 2db18f20..4134fb1a 100644
--- a/utf8.c
+++ b/utf8.c
@@ -167,7 +167,7 @@ static size_t xmbstowcs (wchar_t *dest, const char *src, size_t len,
 	while (src && (len || !dest)) {
 		size_t res;
 
-		res = mbsrtowcs (dest, &src, len, &ps);
+		res = mbsrtowcs (dest, &src, dest ? len : 0, &ps);
 		if (res != (size_t)-1) {
 			count += res;
 			src = NULL;
